<%@ page language="java" import="java.sql.*" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<center>
<font size =5>
<p>人员信息列表
</font>
</center>
<%
Connection con = null;
Statement st = null;
ResultSet rs =null;
try{
	Class.forName("com.mysql.jdbc.Driver");
	con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","lishanshan");
	st = con.createStatement();
	rs = st.executeQuery("select * from gwc");
%>
<a href="addPerson.jsp">新增人员信息</a>
<br/>
<br/>
<table border="1" width="100%" cellpadding ="2" cellspacing="1">
<tr>
<td>选择</td>
<td>姓名</td>
<td>年龄</td>
<td>性别</td>
<td>生日</td>
<td>备注</td>
<td>操作</td>
</tr>
<%
while(rs.next()){
	
	int id = rs.getInt("id");
	String name = rs.getString("name");
	int age= rs.getInt("age");
	String sex = rs.getString("sex");
	Date birthday = rs.getDate("birthday");
	String descriptions = rs.getString("descriptions");
	out.println("<tr>");
	out.println("<td><input type=\"checkbox\" name=\"checkPerson\" value=\""+id+"\"></td>");
	out.println("<td>"+name+"</td>");
	out.println("<td>"+age+"</td>");
	out.println("<td>"+sex+"</td>");
	out.println("<td>"+birthday+"</td>");
	out.println("<td>"+descriptions+"</td>");
	out.println("<td><a href=\"modify.jsp?id="+id+"\">修改</a>&nbsp;&nbsp;"+"<a href=\"delete.jsp?id="+id+"\" onclick=\"return confirm('确定删除记录?')\">删除</a></td>");
out.println("</tr>");

}
%>
</table>
<%
}catch(SQLException e){
	e.printStackTrace();
}finally{
	try{
		rs.close();
		st.close();
		con.close();
	}catch (SQLException e){
		e.printStackTrace();
		
	}
}
%>
</body>
</html>